-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add syntax for Bitraverse to allow traversal and sequencing of the left side #2606
Add syntax for Bitraverse to allow traversal and sequencing of the left side #2606
Conversation
This adds syntax for: * traverse * sequence * leftTraverse * leftSequence I am open to having better names, but I think these would be useful to have in cats-core.
} | ||
|
||
final class BitraverseOps[F[_, _], A, B](val fab: F[A, B]) extends AnyVal { | ||
def bitraverse[G[_]: Applicative, C, D](f: A => G[C], g: B => G[D])(implicit F: Bitraverse[F]): G[F[C, D]] = | ||
F.bitraverse(fab)(f, g) | ||
def traverse[G[_], C](f: B => G[C])(implicit F: Bitraverse[F], G: Applicative[G]): G[F[A, C]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this one and sequence
, we already have them defined on Traverse
and I think that can cause complications. Maybe we should remove these or rename them to rightTraverse
and rightSequence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure about this, but I'll change it to rightTraverse
and rightSequence
for now. You don't normally have syntax in scope to give you traverse
and sequence
, so I do think they're still valuable to have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a ton for opening this, I left a couple of comments :)
Looks like this isn't binary compatible, @andimiller would you mind adding these implicit conversions to a new trait like https://github.com/typelevel/cats/pull/2600/files ? |
I have no idea how binary compatibility works, but I can give it a go copying how that PR does it |
Codecov Report
@@ Coverage Diff @@
## master #2606 +/- ##
==========================================
+ Coverage 95.13% 95.15% +0.02%
==========================================
Files 365 365
Lines 6757 6773 +16
Branches 286 309 +23
==========================================
+ Hits 6428 6445 +17
+ Misses 329 328 -1
Continue to review full report at Codecov.
|
I think I've managed to make it binary compatible, I've left |
Should I have made a new |
I believe it'll be fine if you add it to bincompat3. As long as you get this merged before 1.5.0 is released :) |
I think there should be no
|
I've changed this to only provide |
@andimiller Hi, are you still on this ? Now that 1.5.0 is out this will have to go into a bincompat4. |
@ikempf yeah I'll be updating this PR later today to put it in bincompat4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for keeping this up to date :)
Seems like there's a bug in the travis reporting, I'm going to close/reopen :) |
Thanks! @andimiller Adding some doctests, an example, would be helpful. Although I admit that a doctest here would be hard to find. I'll leave that to you. |
I've added doctests to these syntax methods, I did look at adding these methods directly onto I also can't figure out how to run doctests, so I've pushed it to see if travis manages it better than I can locally. |
@andimiller thanks for adding them. simple |
This adds Bitraverse-based syntax for: